package com.lnking.lnkingplace.controller;


import com.lnking.common.http.ReturnResult;

import com.lnking.lnkingplace.model.dto.activity.ActivityDetailDto;
import com.lnking.lnkingplace.model.dto.rectification.RectificationDetailDto;
import com.lnking.lnkingplace.model.entity.Inspect;
import com.lnking.lnkingplace.model.entity.InspectResult;
import com.lnking.lnkingplace.model.request.inspect.InspectResultRequest;
import com.lnking.lnkingplace.model.request.rectification.*;
import com.lnking.lnkingplace.service.IRectificationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sn
 * @since 2022-08-19
 */
@Api(tags = "整改方案")
@RestController
@RequestMapping("/rectification")
public class RectificationController {

    @Autowired
    IRectificationService rectificationService;
//
//    @ApiOperation("新增")
//    @PostMapping("/add")
//    public ReturnResult add(@RequestBody @Valid RectificationAddRequest params) throws Exception {
//        rectificationService.add(params);
//        return ReturnResult.success();
//    }
//
//    @ApiOperation("删除")
//    @DeleteMapping("/{id}")
//    public ReturnResult delete(@PathVariable("id") String id) {
//        rectificationService.removeById(id);
//        return ReturnResult.success();
//    }
//
//    @ApiOperation("编辑")
//    @PostMapping("/update")
//    public ReturnResult update(@RequestBody @Valid RectificationUpdateRequest params) throws Exception {
//        rectificationService.update(params);
//        return ReturnResult.success();
//    }

//    @ApiOperation("查询列表")
//    @GetMapping("/list")
//    public ReturnResult getList(RectificationSearchRequest params) {
//        return ReturnResult.success(rectificationService.pageList(params));
//    }


    @ApiOperation("商户确认完成整改")
    @PostMapping("/finish")
    public ReturnResult finish(@RequestBody InspectResultTrueRequest params) {
        rectificationService.finish(params);
        return ReturnResult.success();
    }

    @ApiOperation("商户结果确认")
    @GetMapping("/result/status/true")
    public ReturnResult resultStatus(String inspectId  ,String placeId) {
        rectificationService.resultStatus(inspectId,placeId);
        return ReturnResult.success();
    }

    @ApiOperation("复查")
    @PostMapping("/review")
    public ReturnResult review(@RequestBody InspectResult  params) throws Exception {
        rectificationService.review(params);
        return ReturnResult.success();
    }

    @ApiOperation("复查结果")
    @PostMapping("/review/result/{rectificationId}")
    public ReturnResult reviewResult(@PathVariable("rectificationId") String rectificationId) throws Exception {
        rectificationService.reviewResult(rectificationId);
        return ReturnResult.success();
    }


    @ApiOperation("获取整改详情")
    @GetMapping("/{id}")
    public ReturnResult getDetail(@PathVariable("id") String id) {
        RectificationDetailDto detail = rectificationService.getDetailById(id);
        return ReturnResult.success(detail);
    }


    @ApiOperation("获取当前场所对应检查方案需要整改的")
    @GetMapping("/get-fail/{placeId}")
    public ReturnResult getFail(@PathVariable("placeId") String placeId) {
        List<Inspect>   list=rectificationService.getFail(placeId);
        return ReturnResult.success(list);
    }


}
